import { lazy } from "react"
import Login from '@/views/User/Login/index'
import { Redirect } from "react-router-dom";
const Error = lazy(() => import('@/views/err/404.jsx'));
const Home = lazy(() => import('@/views/home/index.jsx'));
const FindPassword = lazy(() => import('@/views/User/FindPassword/index'));
const Register = lazy(() => import('@/views/User/Register/index'));
const WorkForm = lazy(() => import('@/views/WorkInfo/WorkForm/index'));
const WorkYears = lazy(() => import('@/views/Echarts/WorkYears/index'));
const employment = lazy(() => import('@/views/Echarts/employment/index'));
const sexstract = lazy(() => import('@/views/Echarts/sexstract/index'));
const map = lazy(() => import('@/views/Echarts/map/index'));
const college = lazy(() => import('@/views/Echarts/college/index'));
const major = lazy(() => import('@/views/Echarts/major/index'));
const forum = lazy(() => import('@/views/forum/index'));
const chat = lazy(() => import('@/views/forum/chat/index'));
const type = lazy(() => import('@/views/jur/type/index'));
const juruser = lazy(() => import('@/views/jur/juruser/index'));
const account = lazy(() => import('@/views/admin/account/index'));
const authentication = lazy(() => import('@/views/admin/authentication/index'));
const upload = lazy(() => import('@/views/admin/upload/index'));


// 学习路由
const context = lazy(() => import('@/views/hooks/useContext'));
const Reduxs = lazy(() => import('@/views/hooks/reduxs'));

const routes= [
            {
                path: "/home",
                exact:true,
                meta: {
                    id: 991,
                    title: "home页面",
                    needToken: true,
                    isKeepLive: false
                },
                render: () => {
                    return  <Redirect to="/home/workform"></Redirect>
                },
            },
            {
                path: "/home/workform",
                component: WorkForm,
                meta: {
                    id: 11,
                    title: "就业升学信息/就业升学表格",
                    needToken: true,
                    isKeepLive: false
                },
            },
            {
                path: "/home/workyears",
                component: WorkYears,
                meta: {
                    id: 21,
                    title: "就业升学可视化/就业升学一览",
                    needToken: true,
                    isKeepLive: false
                },
            },
            {
                path: "/home/employment",
                component: employment,
                meta: {
                    id: 22,
                    title: "就业升学可视化/学历结构",
                    needToken: true,
                    isKeepLive: false
                },
            },
            {
                path: "/home/sexstract",
                component: sexstract,
                meta: {
                    id: 23,
                    title: "就业升学可视化/性别占比",
                    needToken: true,
                    isKeepLive: false
                },
            },
            {
                path: "/home/map",
                component: map,
                meta: {
                    id: 24,
                    title: "就业升学可视化/就业分布",
                    needToken: true,
                    isKeepLive: false
                },
            },
            {
                path: "/home/college",
                component: college,
                meta: {
                    id: 25,
                    title: "就业升学可视化/学院详情",
                    needToken: true,
                    isKeepLive: false
                },
            },
            {
                path: "/home/major",
                component: major,
                meta: {
                    id: 26,
                    title: "就业升学可视化/专业详情",
                    needToken: true,
                    isKeepLive: false
                },
            },
            {
                path: "/home/forum",
                component: forum,
                meta: {
                    id: 31,
                    title: "论坛中心/学生论坛",
                    needToken: true,
                    isKeepLive: false
                },
            },
            {
                path: "/home/chat",
                component: chat,
                meta: {
                    id: 31,
                    title: "论坛中心/聊天室",
                    needToken: true,
                    isKeepLive: false
                },
            },
            {
                path: "/home/type",
                component: type,
                meta: {
                    id: 41,
                    title: "权限管理模块/分类权限管理",
                    needToken: true,
                    isKeepLive: false
                },
            },
            {
                path: "/home/juruser",
                component: juruser,
                meta: {
                    id: 42,
                    title: "权限管理模块/用户权限管理",
                    needToken: true,
                    isKeepLive: false
                },
            },
            {
                path: "/home/account",
                component: account,
                meta: {
                    id: 51,
                    title: "管理模块/账号信息管理",
                    needToken: true,
                    isKeepLive: false
                },
            },
            {
                path: "/home/authentication",
                component: authentication,
                meta: {
                    id: 52,
                    title: "管理模块/就业信息上传",
                    needToken: true,
                    isKeepLive: false
                },
            },
            {
                path: "/home/upload",
                component: upload,
                meta: {
                    id: 53,
                    title: "管理模块/教师资格认证",
                    needToken: true,
                    isKeepLive: false
                },
            }


        ]
const defaultRoutes=[
    {
        path: "/home",
        component:Home,
        meta: {
            id: 991,
            title: "home页面",
            needToken: true,
            isKeepLive: false
        }
    },
    {
        path: "/login",
        component: Login,
        meta: {
            id: 0,
            title: "登录",
            needToken: false,
            isKeepLive: false
        }
    },

    {
        path: "/register",
        component: Register,
        meta: {
            id: 1,
            title: "注册",
            needToken: false,
            isKeepLive: false
        }
    },
    {
        path: "/findpassword",
        component: FindPassword,
        meta: {
            id: 2,
            title: "找回密码",
            needToken: false,
            isKeepLive: false
        }
    },
    {
        path: "/hooks/context",
        component: context,
        meta: {
            id: 998,
            title: "hooks",
            needToken: false,
            isKeepLive: false
        }
    },
    {
        path: "/redux/redux",
        component: Reduxs,
        meta: {
            id: 990,
            title: "reduxs",
            needToken: false,
            isKeepLive: false
        }
    },
    {
        path: "/",
        component: Login,
        meta: {
            id: 990,
            title: "Login",
            needToken: false,
            isKeepLive: false
        }
    },
  
    {
        path: "*",
        component: Error,
        meta: {
            id: 4,
            title: "404",
            needToken: false,
            isKeepLive: false
        }
    }
]

// 动态生成路由列表
function handleRouters(arr){
    let routesCopy=[]
    routes.forEach(item=>{
        arr.forEach(item1=>{
        if(item.meta.id===item1){
            routesCopy.push(item) 
        }
        }) 
    })

    // console.log(routesCopy)

    return routesCopy

}

export {
routes,
defaultRoutes,
handleRouters
}